const Mock = require('mockjs')

const PurchaseList=[];
for(let i=0;i<100;i++){
    PurchaseList.push(
        Mock.mock({
            id:'@increment',
            purchasenumber:'@integer(111111,999999)',
            purchasechannel:'@first',
            carname:'@first',
            supplier:'@first',
            price:'@integer(10,9999)',
            paystage:'@integer(10,999)',
            paynotice:'@integer(10,999)',
            guider:'@first',
            state:'@integer(0,1)',
            remark:'',
            createtime:'@datetime'
        })
    )
}

const CustomerList=[];
for(let i=0;i<100;i++){
  CustomerList.push(
      Mock.mock({
          id:'@increment',
          customerphone:'@integer(11111111,99999999)',
          customername:'@first',
          car:'@first',
          guider:'@first',
          remark:'',
          createtime:'@datetime'
      })
  )
}

const RedemptecertList=[];
for(let i=0;i<100;i++){
  RedemptecertList.push(
      Mock.mock({
          id:'@increment',
          buynumber:'@integer(11111111,99999999)',
          buydate:'@datetime',
          vincode:'@integer(11111,999999)',
          car:'@first',
          financemoney:'@first',
          financecompany:'@first',
          financetype:'@integer(1,3)',
          percent:'@integer(0,50)',
          redempteday:'@integer(10,100)',
          state:'@integer(0,3)',
          guider:'@first',
          remark:'',
          createtime:'@datetime'
      })
  )
}

const LicenseFeeList=[];
for(let i=0;i<100;i++){
  LicenseFeeList.push(
      Mock.mock({
          id:'@increment',
          buscount:'@integer(1,300)',
          totolmoney:'@integer(11111,999999)',
          state:'@integer(0,3)',
          guider:'@first',
          remark:'',
          createtime:'@datetime'
      })
  )
}

module.exports=[
    {
        url: '/api/finance/vehiclepurchase',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PurchaseList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
      url: '/api/finance/customerlist',
      type: 'get',
      response: config => {
        let { name, page = 1, limit = 20, sort } = config.query
  
        let mockList = PurchaseList.filter(item => {
          return true
        })

        limit=parseInt(Math.random()*3);
        
        const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
  
        return {
          code: '10000',
          data: {
            total: mockList.length,
            items: pageList
          }
        }
      }
    },
    {
      url: '/api/finance/redemptecert',
      type: 'get',
      response: config => {
        const { name, page = 1, limit = 20, sort } = config.query
  
        let mockList = RedemptecertList.filter(item => {
          return true
        })

  
        const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
  
        return {
          code: '10000',
          data: {
            total: mockList.length,
            items: pageList
          }
        }
      }
    },
    {
      url: '/api/finance/licensefee',
      type: 'get',
      response: config => {
        const { name, page = 1, limit = 20, sort } = config.query
  
        let mockList = LicenseFeeList.filter(item => {
          return true
        })

  
        const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
  
        return {
          code: '10000',
          data: {
            total: mockList.length,
            items: pageList
          }
        }
      }
    },
]